<template>
	<view class="container">
		<!--消息提示-->
		<u-notify ref="notify"></u-notify>

		<view>请将导出的文本复制下来，方便下次导入使用</view>
		<button @click="copy" class="copy">复制到剪切板</button>
		<view class="token">{{token}}</view>
	</view>
</template>
<script>
import moment from 'moment';
export default {
	data() {
		return {
			// 生成的token
			token: null
		};
	},
	created() {
		// 获取密码列表
		let passwordList = this.passwordService.getPasswordList();
		// 获取导出时间
		let exportTime = moment().format('yyyy-MM-DD HH:mm:ss');
		// 获取序列
		let sequence = uni.getStorageSync('sequence');
		// 生成token
		this.token = this.jwt.getToken({
			passwordList,
			exportTime,
			sequence
		});
	},
	methods: {
		/**
		 * 复制
		 */
		copy() {
			uni.setClipboardData({
				data: this.token,
				showToast: false,
				success: () => this.$refs.notify.success('复制成功')
			});
		}
	}
}
</script>
<style scoped>
.container {
	padding: 10px;
}
/*复制按钮*/
.copy {
	width: 100%;
	height: 40px;
	line-height: 40px;
	border-radius: 20px;
	background-color: #409EFF;
	color: white;
	margin: 15px 0;
}
/*token*/
.token {
	color: #aaaaaa;
	overflow: hidden;
	text-overflow: ellipsis;
	display: -webkit-box;
	-webkit-box-orient: vertical;
	display: -moz-box;
	-moz-box-orient: vertical;
	word-wrap: break-word;
	word-break: break-all;
	white-space: normal;
}
</style>
